com.cete.dynamicpdf
Class PageReaderEvents
Example : The following example shows how to use page reader events.
import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;
import com.cete.dynamicpdf.pageelements.forms.*;
public class MyClass {
public static void main(String args[]) {
// Create a PDF Document
Document document = new Document();
// Create pages and add it to the document
Page page = new Page();
Page page1 = new Page();
document.getPages().add(page);
document.getPages().add(page1);
// Create labels and add it to the page
Label label1 = new Label("Page Additional Actions", 50, 50, 400, 50, Font.getCourier(), 20);
Label label2 = new Label("Go to the second page to see the page open action", 50, 150, 300, 50, Font.getCourier(), 15);
Label label3 = new Label("Second page", 50, 100, 300, 50, Font.getCourier(), 15);
page.getElements().add(label1);
page.getElements().add(label2);
page1.getElements().add(label3);
// Create a java script action and assign to the page reader event.
JavaScriptAction action = new JavaScriptAction("app.alert(\"Welcome to the second page!!\")");
page1.getReaderEvents().setOpen(action);
// Save the PDF
document.draw( "[physicalpath]/MyDocument.pdf" );
}
}